home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-05-28 | 1.8 KB | 89 lines | [TEXT/CWIE] |
- /*
- File: CodeModuleUtils.cp
-
- Contains: Utilities for use with LCodeModule.
-
- Copyright: ©1995 Chris K. Thomas. All Rights Reserved.
-
- Version: 1.0
-
- History: ckt August 10, 1995 created.
- ckt May 1, 1996 total rewrite.
-
- Requires PowerPlant array classes and MoreFiles.
- */
-
- #include <LArray.h>
- #include "IterateDirectory.h"
- #include "TCodeModule.h"
-
- #include "CodeModuleUtils.h"
-
-
- //
- // static methods
- //
-
- static pascal void CodeModuleIterator (const CInfoPBRec * const cpbPtr,
- Boolean *quitFlag,
- LArray *ourArray);
-
- static OSType sFileType = 0L;
-
- //
- // * load code modules into a preallocated array
- //
- OSStatus LoadCodeModulesFromFolder(OSType inFileType, FSSpec *inFolder, LArray &outModuleArray)
- {
- OSStatus theErr = 0;
-
- sFileType = inFileType;
-
- //
- // clear existing list if necessary
- //
- if(outModuleArray.GetCount() > 0)
- outModuleArray.RemoveItemsAt(outModuleArray.GetCount(), 1);
-
- //
- // get all potential code modules
- //
-
- theErr = FSpIterateDirectory(inFolder, 0, (IterateFilterProcPtr) &CodeModuleIterator, &outModuleArray);
- return theErr;
- }
-
-
- //
- // actual work is done here
- //
- static pascal void CodeModuleIterator (const CInfoPBRec * const cpbPtr,
- Boolean */*quitFlag*/,
- LArray *ourArray)
- {
- //
- // if it’s a directory, we don’t care
- //
-
- if(((cpbPtr->hFileInfo.ioFlAttrib & ioDirMask) == 0)
- && (cpbPtr->hFileInfo.ioFlFndrInfo.fdType == sFileType))
- {
- FSSpec theSpec;
- OSStatus theErr = 0L;
- TCodeModule *currentModule;
-
- theErr = FSMakeFSSpec(cpbPtr->hFileInfo.ioVRefNum, cpbPtr->hFileInfo.ioDirID,
- cpbPtr->hFileInfo.ioNamePtr, &theSpec);
-
- //
- // if we got a module add it to our array
- //
-
- if(theErr == 0L)
- {
- currentModule = new TCodeModule(theSpec);
- ourArray->InsertItemsAt(1, ourArray->GetCount() + 1, ¤tModule);
- }
- }
- }
-